<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Casting SPELs in Lisp - Emacs Lisp Edition, a Comic Book
     Written by Conrad Barski, M.D., http://lisperati.com
     Edited by James A. Webb, http://uberkode.com -->

<head>

  <title>Casting SPELs in Lisp (10)</title>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="author" content="James A. Webb" />
  <meta name="date" content="2007-09-15T00:00:00+00:00" />
  <meta name="keywords" content="Emacs, Lisp" />

</head>

<body>

<center>

<table cellspacing="10" width="500">
  <tr>
    <td>
      In this simple game, there will only be three different 
      locations: a house with a living room and an attic, along 
      with a garden. Let's define a new variable, called <tt>map</tt> 
      that describes this mini world:
    </td>
  </tr>
  <tr>
    <td>
<pre style="font-weight: bolder; color: darkblue">
  (setq map '((living-room (you are in the living room
                of a wizards house - there is a wizard
                snoring loudly on the couch -)
                (west door garden)
                (upstairs stairway attic))
              (garden (you are in a beautiful garden -
                there is a well in front of you -)
                (east door living-room))
              (attic (you are in the attic of the
                wizards house - there is a giant
                welding torch in the corner -)
                (downstairs stairway living-room))))
</pre>
    </td>
  </tr>
  <tr>
    <td>
      This map contains everything important that we'd like to know 
      about our three locations: a unique name for the location (i.e., 
      living room, garden, and attic) a short description of what 
      we can see from there (stored in its own list within the bigger 
      list), plus the where and how of each path in to/out of that 
      place. Notice how information-rich this one variable is and 
      how it describes all we need to know but not a thing more. 
      Lispers love to create small, concise pieces of code that 
      leave out any fat and are easy to understand just by looking 
      at them.
    </td>
  </tr>
  <tr>
    <td>
      Now that we have a map and a bunch of objects, it makes sense 
      to create another variable that says where each of these 
      objects are on the map:
    </td>
  </tr>
  <tr>
    <td>
<pre style="font-weight: bolder; color: darkblue">
  (setq object-locations '((whiskey-bottle living-room)
                           (bucket living-room)
                           (chain garden)
                           (frog garden)))
</pre>
    </td>
  </tr>
  <tr>
    <td align="center">
      &lt;&lt; <a href="casting-spels-emacs-1.html">begin</a>
      &lt; <a href="casting-spels-emacs-9.html">previous</a> - 
      <a href="casting-spels-emacs-11.html">next</a> &gt;
      <a href="casting-spels-emacs-35.html" >end</a> &gt;&gt;
    </td>
  </tr>
</table>

</center>

</body>

</html>